﻿@using ZBJF.Warranty.BLL
@using ZBJF.Warranty.Common.Common
@using ZBJF.Warranty.Common.Enums.InsuranceProducts
@using ZBJF.Warranty.Model
@model SellerInsuranceProducts
    @{
        ViewBag.Title = "产品详情";
        var currentUser = CurrentLoginUser.CurrentUser;
        var sellerId = currentUser != null ? CurrentLoginUser.CurrentUser.SellerId : long.Parse(Request["SellerId"] ?? "0");
        var sellerEmployeeID = currentUser != null ? CurrentLoginUser.CurrentUser.ID : long.Parse(Request["SellerEmployeeID"] ?? "0");
        if (sellerId <= 0 || sellerEmployeeID <= 0)//未登录
        {
            Response.Redirect("/home");
        }
        var saleQty = ServiceFactory.InsuranceProductOrderServiceInstance.GetSellerInsuranceProductSaleCount(string.Empty, sellerEmployeeID, Model.ID, InsuranceProductOrderStatus.Paid);
        var shareUrl = "http://" + Request.Url.Authority + "/InsuranceProduct/ToBeCreateInsuranceOrder?id=" + Model.ID + "&SellerId=" + sellerId + "&SellerEmployeeID=" + sellerEmployeeID;
    }
    <script src="~/Scripts/jquery-ui.js"></script>
    <link href="~/Content/jquery-ui.css" rel="stylesheet" />

    <div class="desc_forward_title" onclick="history.back(-1)">
        产品详情
    </div>
    <div class="product_top_header">
        <div class="product_top_title">
            <div class="left">
                <hr>
            </div>
            <div class="text">@Model.ProductName</div>
            <div class="right">
                <hr>
            </div>
        </div>
        <div class="price"><label>￥</label>@Model.SaleRetailPrice</div>
        <div class="sale-count">销量 @saleQty&nbsp;份</div>
    </div>
    <div class="weui-tab">
        <div class="weui-navbar">
            @if (currentUser != null)
            {
                <a class="weui-navbar__item  weui-bar__item--on" href="#tab2">
                    产品介绍
                </a>
                <a class="weui-navbar__item" href="#tab1">
                    扫码购买
                </a>
            }
            else
            {
                <div class="product_buy_title">
                    <a class="align-left" href="#tab2">
                        产品介绍
                    </a>
                </div>
            }
        </div>
        <div class="weui-tab__bd">
            @if (currentUser != null)
            {
                <div id="tab1" class="weui-tab__bd-item">
                    <div class="align-center">
                        <div id="qrcode" class="qrcode" onclick="createQrCode()"></div>
                    </div>
                    <div class="weui-loadmore weui-loadmore_line weui-loadmore_dot">
                        <span class="weui-loadmore__tips">立即分享,快速成交</span>
                    </div>
                </div>
            }
            <div id="tab2" class="weui-tab__bd-item weui-tab__bd-item--active">
                <div class="weui-form-preview">
                    <div class="detail_content">
                        @Html.Raw(Model.Intro)
                    </div>
                    <div class="weui-form-preview__ft weui-footer_fixed-bottom">
                        <a class="weui-form-preview__btn weui-form-preview__btn_primary" id="buybtn" href="/InsuranceOrder/CreateInsuranceOrder/@Model.ID">立即投保</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="~/Scripts/qrcode.js"></script>
    <script type="text/javascript">
        var qrcode;
        var _url = '@(HttpUtility.HtmlDecode(shareUrl))'.replace(/&amp;/g, "&") + "&t=" + new Date().getTime();
        $(function () {
            var qrcodeDiv = $("#qrcode").html();
            if (qrcodeDiv == undefined) return;
            qrcode = new QRCode('qrcode', {
                text: _url,
                width: 256,
                height: 256,
                colorDark: '#000000',
                colorLight: '#ffffff',
                correctLevel: QRCode.CorrectLevel.H
            });
        });
        function createQrCode() {
            qrcode.clear();
            qrcode.makeCode('@(HttpUtility.HtmlDecode(shareUrl))'.replace(/&amp;/g, "&") + "&t=" + new Date().getTime());
        }
    </script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script src="~/Scripts/WeiXinJsApi.js?v=2"></script>
